package com.lmh.framework.mvc;

import com.lmh.framework.exception.MyException;
import com.lmh.utils.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalControllerAdvice {

    @ResponseBody
    @ExceptionHandler(RuntimeException.class)
    public Result handleException(RuntimeException e) {
        e.printStackTrace();
        return Result.fail(e.getMessage());
    }

    @ResponseBody
    @ExceptionHandler(MyException.class)
    public Result handleException(MyException e) {
        e.printStackTrace();
        return Result.fail(e.getMessage());
    }

}
